import 'package:animal/network/api.dart';
import 'package:animal/ui/friend/NWApi.dart';
import 'package:animal/ui/friend/model/new_friend_model.dart';
import 'package:animal/ui/friend/page/friend_apply_info_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class NewFriendController extends GetxController{
  //好友申请列表data
  var data = <Records>[].obs;

  @override
  void onInit() {
    super.onInit();
    getFriendsApply();
  }

  ///获取好友申请列表
  void getFriendsApply(){
    HttpManager().post<NewFriendModel>(ChatApi.friendApplyPage,queryParameters: {}).listen((value) {
      data.addAll(value.data!.records!);
    },onError: (err){
      debugPrint(err.message);
    });
  }

  ///同意好友申请
  void getAgreeApply(String id){
    HttpManager().post(ChatApi.friendApplyAgree,queryParameters: {"id":id}).listen((value) { },onError: (err){
      debugPrint(err.message);
    });
  }

  ///前往申请详情
  void gotoApplyInfo(){
    Get.to(FriendApplyInfoPage());
  }
}